/********************************************************************************************************************************************************************************
* 
* Class Name  	: 
* Version 	  	: 
* Description 	: 
* 
********************************************************************************************************************************************************************************
* 
* Author 		: Karim Beyrouti
* Date 			: 
* 
********************************************************************************************************************************************************************************
* 
* METHODS
* 
*
* PROPERTIES
* 
*
* EVENTS
* 
* 
********************************************************************************************************************************************************************************
* 				:
*
*
*********************************************************************************************************************************************************************************
* NOTES			:
**********************************************************************************************************************************************************************************/

package com.kurst.air {
	
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;
	import flash.utils.ByteArray;
	
	public class FileIO{
		
		private var fStream : FileStream
		//------------------------------------------------------------------------------------------------------------------------------------------------------------
		
		public function FileIO(){}
		
		//------------------------------------------------------------------------------------------------------------------------------------------------------------
		//-PUBLIC-----------------------------------------------------------------------------------------------------------------------------------------------------
		//------------------------------------------------------------------------------------------------------------------------------------------------------------
		
		/**
		 * @method 
		 * @tooltip
		 * @param
		 * @return
		 */
		public function writeTextFile( file : File , str : String ) : void {
			
			fStream 	= new FileStream();
			
			fStream.open( file, FileMode.WRITE );
			fStream.writeUTFBytes( str );
			fStream.close();
			
			fStream 		= null;
			
			
		}
		/**
		 * @method 
		 * @tooltip
		 * @param
		 * @return
		 */
		public function writeBinaryFile( file : File , byteArray : ByteArray ) : void {
			
			fStream 	= new FileStream();
			
			fStream.open( file, FileMode.WRITE );
			fStream.writeBytes( byteArray );
			fStream.close();
			
			fStream 		= null;
			
		}
		/**
		 * @method 
		 * @tooltip
		 * @param
		 * @return
		 */
		public function readTextFile( file : File ): String{
			
			fStream 			= new FileStream();
			fStream.open(file, FileMode.READ);
			
			var str : String 	= fStream.readUTFBytes(fStream.bytesAvailable);
			fStream.close();
			
			return str;
			
		}
		
		//------------------------------------------------------------------------------------------------------------------------------------------------------------
		//-PRIVATE----------------------------------------------------------------------------------------------------------------------------------------------------
		//------------------------------------------------------------------------------------------------------------------------------------------------------------

		//------------------------------------------------------------------------------------------------------------------------------------------------------------
		//-GET/SET----------------------------------------------------------------------------------------------------------------------------------------------------
		//------------------------------------------------------------------------------------------------------------------------------------------------------------
		
		//------------------------------------------------------------------------------------------------------------------------------------------------------------
		//-EVENT HANDLERS-------------------------------------------------------------------------------------------------------------------------------------------
		//------------------------------------------------------------------------------------------------------------------------------------------------------------
		
	}
	
	
}